
//app.js
App({
  onLaunch: function () {
    this.login();
  },
  login : function () {
    var that = this;
    wx.login({
      success: function (res) {
        var code = res.code; // 微信登录接口返回的 code 参数，下面注册接口需要用到
        wx.request({
          url: that.globalData.server + '/api/wei_applet/user_login',
          data: {
            js_code: code,
            app_id: 'wx137d289220c87a13',
            secret: '163becbe754ca1ee333b0efe40b04139'
          },
          success: function (result) {
            that.globalData.openid = result.data.openid;
            that.globalData.userInfo = result.data.userInfo;
          },
          fail: function () {

          }
        })
      }
    })
  },
  globalData:{
    openid:'',
    subDomain: "mall",
    office_id:'57cdeaa3b20747779f3f4dac026b7771',
    version: "1.4.0",
    server: 'https://nodejs-demo.com',
    appId: 'wx137d289220c87a13',
    mch_id: '1487774662',
    shop_key: '6CB7436C9EF359EC5F184D5706A92296',
    appSecret:'163becbe754ca1ee333b0efe40b04139',
    apiNames: ['WX_CODE', 'WX_CHECK_USER', 'WX_DECODE_USERINFO'],
    imgServer: 'https://nodejs-demo.com/wa/userfiles/images',
    fileServer: 'https://nodejs-demo.com/wa/userfiles/files'
  }
})
